{% extends 'template.html' %}
{% load staticfiles %}

{% block username %}
    {{ request.user.username }}
{% endblock %}

{% block content %}
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h2 class="page-header">流程状态对应审批人配置</h2>
            </div>
        </div>
        <div class="alert alert-info">
            <p><i class="fa fa-check"></i> 维护工单审批过程中，各个状态节点需要增加额外审批人的配置</p>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <div class="btn-group">
                            <a>
                                <button type="button" class="btn btn-success" onclick="bt_add()">新增流程审批人
                                </button>
                            </a>
                            <a>
                                <button id='bt-del' data-text="确定删除审批人? 0个" type="button"
                                        class="btn btn-danger">删除
                                </button>
                            </a>
                        </div>
                    </div>
                    <div class="panel-body">
                        {% if specified_user_state_list %}
                            <table id="mytable" width="100%" cellspacing="0"
                                   class="table table-striped table-hover">
                                <thead>
                                <tr>
                                    <th class="center sorting_disabled">
                                        <label class="pos-rel">
                                            <input id='chb-all' type="checkbox"/>
                                        </label>
                                    </th>
                                    <th style="display: none;">id</th>
                                    <th>流程名称</th>
                                    <th>节点状态</th>
                                    <th>额外审批人</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {% for state in specified_user_state_list %}
                                    <tr>
                                        <td class=" dt-body-center"><input type="checkbox"></td>
                                        <td style="display: none;" id="{{ state.id }}"
                                            value="{{ state.id }}"
                                            name="{{ state.id }}">{{ state.id }}</td>
                                        <td>{{ state.workflow }}</td>
                                        <td>{{ state.state }}</td>
                                        <td>{{ state.specified_user }}</td>
                                        <td>
                                            <button class="btn btn-sm btn-primary" onclick="edit_specified_user({{ state.id }})">
                                                修改
                                            </button>
                                        </td>
                                    </tr>
                                {% endfor %}
                                </tbody>
                            </table>
                        {% else %}
                            <p>还没有审批人信息，请先添加！</p>
                        {% endif %}
                    </div>
                </div>
            </div>

            <!-- Add or Edit Modal-->
            <div class="modal fade" id="Modal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myModalLabel"></h4>
                        </div>
                        <form class="form-horizontal">
                            <div class="modal-body">
                                <div class="alert alert-danger alert-dismissable" id='modal-notify'>
                                    <button type="button" class="close" data-dismiss="alert">&times;</button>
                                    <label id='lb-msg'></label>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">流程名称</label>
                                    <div class="col-md-8">
                                        <select id="id_workflow" class="form-control" style="width: 100%">
                                            <option></option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">审批节点</label>
                                    <div class="col-md-8">
                                        <select id="id_state" class="form-control" style="width: 100%">
                                            <option></option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">额外审批人</label>
                                    <div class="col-md-8">
                                        <select id="id_specified_user" class="form-control" multiple="multiple" style="width: 100%">
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                <button type="button" class="btn btn-primary" name='action'
                                        id="bt-save">保存
                                </button>
                            </div>
                        </form>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal-dialog -->
            </div>

        </div>
    </div>
{% endblock %}
{% block bodyjs %}
    <script src="/static/js/select2.min.js"></script>
    <script src="/static/js/jquery.dataTables.min.js"></script>
    <script src="/static/js/dataTables.colVis.js"></script>
    <script src="/static/js/workflow_state_specified_user.js?v=20190628001"></script>
{% endblock %}
{% block css %}
    <link href="/static/css/jquery.dataTables.css" rel="stylesheet" type="text/css">
    <link href="/static/css/dataTables.colVis.css" rel="stylesheet" type="text/css">
    <link href="/static/css/select2-bootstrap.css" rel="stylesheet" type="text/css">
{% endblock %}
